package com.zhou.util;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.message.BasicNameValuePair;

public class ZhouHttpPostManager {

	public static boolean addUser(String imei, String phone) {
		List<NameValuePair> userParams = new ArrayList<NameValuePair>();
		userParams.add(new BasicNameValuePair("imei", imei));
		userParams.add(new BasicNameValuePair("phone", phone));
		boolean result = false;
		try {
			result = ZhouHttpPostHelper.commit("adduser", userParams);
		} catch (ClientProtocolException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
	}
	
	public static boolean updateLoadTime(String imei , int loadTime){
		boolean result = false;
		List<NameValuePair> loadTimeParams = new ArrayList<NameValuePair>();
		loadTimeParams.add(new BasicNameValuePair("imei", imei));
		loadTimeParams.add(new BasicNameValuePair("loadTime", loadTime+""));
		try {
			result = ZhouHttpPostHelper.commit("userinfo", loadTimeParams);
		} catch (ClientProtocolException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	
		return result;
	}
	
	public static boolean addNote(String imei,String note , String contact,String name ){
		boolean result = false ;
		List<NameValuePair> noteParams = new ArrayList<NameValuePair>();
		noteParams.add(new BasicNameValuePair("imei", imei));
		noteParams.add(new BasicNameValuePair("note", note));
		noteParams.add(new BasicNameValuePair("contact", contact));
		noteParams.add(new BasicNameValuePair("name", name));
		
		try {
			result  = ZhouHttpPostHelper.commit("addnote", noteParams);
		} catch (ClientProtocolException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return result;
	}
	

}
